package com.example.service.impl;

import com.example.dao.TopicDao;
import com.example.dao.impl.TopicDaoImpl;
import com.example.pojo.Topic;
import com.example.service.TopicService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service("topicService")
public class TopicServiceImpl implements TopicService {
    @Resource(name = "topicDao")
    public TopicDao topicDao;

    public List<Map<String,Object>> getHotTopicList() {
        return topicDao.getHotTopicList();
    }

    public List<Map<String,Object>> getNewTopicList() {
        return topicDao.getNewTopicList();
    }

    public List<Map<String,Object>> getNiceTopicList() {
        return topicDao.getNiceTopicList();
    }

    public List<Map<String,Object>> getSpecificTypeList(String type) {
        return topicDao.getSpecificTypeList(type);
    }

    public List<Map<String,Object>> getCommentList(Integer tId) {
        return topicDao.getCommentList(tId);
    }

    public List<Map<String,Object>> getGoodTopicList(String goodType) {
        return topicDao.getGoodTopicList(goodType);
    }

    public List<Map<String,Object>> getSearchList(String words) {
        return topicDao.getSearchList(words);
    }



    public Boolean selectIsLike(Integer uId,Integer tId) {
        int res = topicDao.selectIsLike(uId,tId);
        if(res == 1) {
            return true;
        } else {
            return false;
        }
    }

    public Integer saveLike(Integer uId,Integer tId,Boolean isLike) {
        int res = topicDao.saveLike(uId,tId,isLike);
        if(res == 1) {
            return 200;
        } else {
            return 500;
        }
    }

    public Boolean selectIsCollection(Integer uId,Integer tId) {
        int res = topicDao.selectIsCollection(uId,tId);
        if(res == 1) {
            return true;
        } else {
            return false;
        }
    }

    public Integer saveCollection(Integer uId,Integer tId,Boolean isCollection) {
        int res = topicDao.saveCollection(uId,tId,isCollection);
        if(res == 1) {
            return 200;
        } else {
            return 500;
        }
    }

    public Integer insertTopic(Integer uId,String title,String type,String realStatus,String content) {
        int res = topicDao.insertTopic(uId,title,type,realStatus,content);
        if(res == 1) {
            return 200;
        } else {
            return 500;
        }
    }
}
